<?php

namespace App\Http\Controllers\Model;

use DB;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use EasyWeChat\Foundation\Application;
use App\Http\Controllers\Controller;
use App\Http\Models\Modelblock;
use App\Http\Models\Modelinit;

class EditHtmlController extends Controller {


    //编辑模块参数用的
    public function edit($modelId){
        return view('model.edithtml',['modelId'=>$modelId]);
    }


    //解析参数返回模块模版
    public function parse($modeId,$modelName){
        $modelblock = Modelblock::where('modelid',$modeId)->first();
        $param = json_decode($modelblock['modelparam'],true);
        return view('model.show.imagetext',$param);
    }

    //保存参数
    public function save(Request $request){
        $modelId = $request->input('modelId');
        $src = $request->input('src');
        $param = json_encode(['src'=>$src]);
        Modelblock::where('modelid',$modelId)->update(['modelparam'=>$param]);
        return response()->json(['state'=>'ok','message'=>'操作成功']);
    }

}
